package com.hotel.daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.hotel.dao.RecordUser;
import com.hotel.pojo.User;

import DBUtil.JdbcUtil;

public class RecordUserImpl  implements RecordUser{
     User user=null;
     Connection conn=null;
     PreparedStatement ps=null;
     ResultSet rs=null;
	@Override
	public User AddRecordUser(User user) {
       try {
    	conn=JdbcUtil.getConnection();
    	String sql="insert into t_RecordUser(rname,rphonenumber,ridentify,rdept,rdate) values(?,?,?,?,?)";
    	ps=conn.prepareStatement(sql); 
		ps.setString(1,user.getRname());
		ps.setString(2,user.getRphonenumber());
		ps.setString(3, user.getIdentify());
		ps.setString(4, user.getRdept());
		ps.setDate(5, user.getRdate());		
		int count=ps.executeUpdate();
			System.out.println(count);		
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		JdbcUtil.close(rs, ps, conn);	
	}			
		return user;
	}
}
